package com.zs.toolbox.web2j.system.core.controller.admin;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zs.toolbox.web2j.common.request.WtPageBodyModel;
import com.zs.toolbox.web2j.common.request.WtPageQuerySearchModel;
import com.zs.toolbox.web2j.common.response.WtBaseResponse;
import com.zs.toolbox.web2j.common.web.WtAdminBaseController;
import com.zs.toolbox.web2j.system.core.entity.WtPermissionEntity;
import com.zs.toolbox.web2j.system.core.service.WtPermissionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 用户基本信息操作
 * </p>
 *
 * @author eric.zhang
 * @since 2018-09-21
 */
@RequestMapping("/api/v1/admin/permission/")
@Api(description = "运营权限管理")
@Slf4j
@RestController
public class WtAdminPermissionController extends WtAdminBaseController<WtPermissionService, WtPermissionEntity,Long> {

    public WtBaseResponse<WtPageBodyModel<WtPermissionEntity>> getPage(@RequestBody WtPageQuerySearchModel wtPageQueryModel) {
        wtPageQueryModel.setSearchKey(getTableField(WtPermissionEntity.class,wtPageQueryModel.getSearchKey()));
        return super.getPage(wtPageQueryModel);
    }

    @RequestMapping(value = "menuPermission", method = {RequestMethod.POST, RequestMethod.GET})
    @ApiOperation("获得所有菜单类权限与菜单对应关系表")
    public WtBaseResponse<List<WtPermissionEntity>> getMenuPersmison() {
        List<WtPermissionEntity> wtPermissionEntities = baseService.list(new LambdaQueryWrapper<WtPermissionEntity>()
                .eq(WtPermissionEntity::getPermissionType, "menu"));
        return new WtBaseResponse(wtPermissionEntities);
    }

}
